<?php
header('Content-Type: text/html; charset=UTF-8');
require("./includes/config.inc"); /* this is a config file that new users/installations need to edit */
require('./includes/variables.inc'); 
require('./includes/auth.inc');  // authentication

if ($U_[id]) {

//<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
//<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
?>
<html>
<head><title>c-cramp for <?php echo($CALL_LETTERS.' '.$FREQUENCY) ?></title>
<link rel="icon" href="themes/default/img/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="themes/default/img/favicon.ico" type="image/x-icon">
<style>
body {
   border: 0px;
   margin: 0px;
   }
table {
   margin: 0px;
   border: 0px;
   padding: 0px;
   }
td {
   margin: 0px;
   border: 0px;
   padding: 0px;
   }
iframe {
   margin: 0px;
   border: 0px;
   padding: 0px;
   height: 100%;
   width: 100%;
   }
.albumContext {
   visibility: visible;
   display: block;
   background-color: white;
   border: 1px solid #d6e6ff;
   width: 350px;
   height: 300px;
   }
.srchCtxt {
   align: right;
   text-align: right;
   visibility: visible;
   display: block;
   background-color: #e0e0e0;
   border: 1px; solid #d6e6ff; 
/*
   width: 120px;
   height: 170px;
*/
   }
td.albCtxt {
   background-color: #d6e6ff;
   width: 100%;
   height: 285px;
   }
tr.albCtxt {
   width: 100%;
   height: 100%;
tb.albCtxt {
   width: 100%;
   height: 300px;
   }
iframe.albCtxt {
   width: 100%;
   height: 100%;
   }
#iframeContext {
   width: 350px;
   height: 300px;
   }
.hidden {
	width: 0px; 
	visibility: hidden;
	display: none!important; 
	}
.normalContext {
   visibility: visible;
   display: block;
   background-color: #c0c0c0;
   border: 1px solid #d6e6ff;
   }
#contextMenu {
   position: absolute;
   left: 0px;
   top: 0px;
   z-index: 50;
   }
</style>
<script language="javascript" type="text/javascript" src="./includes/javascript/dom-drag.js"></script>

<script language="javascript" text="text/javascript">
function srchCtxt (posX, posY) {
   var targetDiv = document.getElementById('contextMenu'); 
   targetDiv.style.left = (posX + 2) + 'px'; //event.clientY + 25 + 'px'; 
   targetDiv.style.top = (posY + 9) + 'px';
   targetDiv.style.position = 'absolute'; 
   targetDiv.className = 'srchCtxt';
//   var targetHidden = 'document.getElementById(\'contextMenu\').className = \'hidden\'; document.getElementById(\'contextMenu\').innerHTML=\'\';';
//   targetDiv.setAttribute('onMouseout', targetHidden);
     targetDiv.innerHTML = frames['sideHead'].document.getElementById('contextContent').innerHTML;
//   targetDiv.innerHTML = '<span onClick="destroyContext();">X</span><br /><span onClick="frames[sideHead].setStatus(\'all\');">all</span><br /><span onClick="frames[sideHead].setStatus(1);">in review</span><br /><span onClick="frames[sideHead].setStatus(2);">new</span><br /><span onClick="frames[sideHead].setStatus(3);">old</span><br /><span onClick="frames[sideHead].setStatus(4);">ancient</span><br />';
   
//   targetDiv.innerHTML = '<table class="albCtxt"><tr><td class="albCtxt" style="height:14px; width: 330px;">' + art + '</td><td style="text-align: right;"><a onClick="parent.destroyContext()"><img src="./themes/default/img/close.png" /></a></td></tr><tr class="albCtxt"><td class="albCtxt" colspan="2"><iframe id="albInfo" class="albCtxt"></iframe></td></tr></table>';
//   var targetFrame = document.getElementById('albInfo');
//   if (srchType == 'art') {
//      targetFrame.src = './widgets/albumInfoContext.php?artist=' + srchStr;
//   } else if (srchType == 'alb') {
//      targetFrame.src = './widgets/albumInfoContext.php?albId=' + srchStr;
//   }
//   targetFrame.setAttribute('target','main');
   //targetFrame.setAttribute('onMouseout','parent.document.getElementById(\'iframeContext\').className = \'hidden\';');
}

function albInfoCtxt (srchType, srchStr) {
   var targetDiv = document.getElementById('contextMenu'); 
   targetDiv.style.top = 100 + 'px'; //event.clientY + 25 + 'px'; 
   targetDiv.style.left = 160 + 'px'; //event.clientX + 25 + 'px'; 
   targetDiv.style.position = 'absolute'; 
   targetDiv.className = 'albumContext';
   if (srchType == 'art') {
      var art = srchStr;
      art = art.replace(/\+/g, ' ');
      art = art.replace(/\%2F/g, '/');
      art = art.replace(/\%26/g, '&');
   } else if (srchType == 'alb') {
      var art = 'Various';
   }
   targetDiv.innerHTML = '<table class="albCtxt"><tr><td class="albCtxt" style="height:14px; width: 330px;">' + art + '</td><td style="text-align: right;"><a onClick="parent.destroyContext()"><img src="./themes/default/img/close.png" /></a></td></tr><tr class="albCtxt"><td class="albCtxt" colspan="2"><iframe id="albInfo" class="albCtxt"></iframe></td></tr></table>';
   var targetFrame = document.getElementById('albInfo');
   if (srchType == 'art') {
      targetFrame.src = './widgets/albumInfoContext.php?artist=' + srchStr;
   } else if (srchType == 'alb') {
      targetFrame.src = './widgets/albumInfoContext.php?albId=' + srchStr;
   }
   targetFrame.setAttribute('target','main');
   //targetFrame.setAttribute('onMouseout','parent.document.getElementById(\'iframeContext\').className = \'hidden\';');
}

function albInfoCtxtProto (srchStr) {
   
   var targetDiv = document.getElementById('contextMenu'); 
   targetDiv.style.top = 100 + 'px'; //event.clientY + 25 + 'px'; 
   targetDiv.style.left = 160 + 'px'; //event.clientX + 25 + 'px'; 
   targetDiv.style.position = 'absolute'; 
   targetDiv.className = 'albumContext';
   
   var splitStr = srchStr.split('||');
   
   var ctxtUrl = './widgets/albumInfoContext.php?';
   for (i=0; i < (splitStr.length - 1); (i = i+2) ) {
      ctxtUrl = ctxtUrl + splitStr[i] + '=' + splitStr[(i+1)] + '&';
   }
//   alert(ctxtUrl);
   
//   if (srchType == 'art') {
//      var art = srchStr;
//      art = art.replace(/\+/g, ' ');
//      art = art.replace(/\%2F/g, '/');
//      art = art.replace(/\%26/g, '&');
//   } else if (srchType == 'alb') {
//      var art = 'Various';
//   }
   targetDiv.innerHTML = '<table class="albCtxt"><tr><td class="albCtxt" id="albCtxtTitle" style="height:14px; width: 330px;"></td><td style="text-align: right;"><a onClick="parent.destroyContext()"><img src="./themes/default/img/close.png" /></a></td></tr><tr class="albCtxt"><td class="albCtxt" colspan="2"><iframe name="albInfoIframe" id="albInfo" class="albCtxt"></iframe></td></tr></table>';
   var targetFrame = document.getElementById('albInfo');
   targetFrame.src = ctxtUrl;
   targetFrame.setAttribute('target','main');
   // here, we should set the title to something in the frame
//   alert(frames['albInfoIframe'].document.getElementById('albInfoTitle'));
//   var targetTitle = document.frames['albInfoIframe'].document.getElementById('albInfoTitle').value;
//   alert('test');
//   alert(targetTitle);
}

function trafTrkAddCtxt (srchType, srchStr, posX, posY) {
//   alert(srchType + ' ' + srchStr);
   var targetDiv = document.getElementById('contextMenu');
   targetDiv.style.top = 300+ 'px';
   targetDiv.style.left = 300 + 'px';
   targetDiv.style.position = 'absolute';
   targetDiv.className = 'albumContext';
   var trafSlot = frames['main'].document.getElementById('trafTrkInputSlot').value;
   targetDiv.innerHTML = '<iframe id="albInfo" class="albCtxt"></iframe>';
//   if (srchType == 'trk') {
//      //
//   }
//   targetDiv.innerHTML = '<table class="albCtxt"><tr class="albCtxt"><td class="albCtxt" style="height:14px; width: 330px;">' + srchStr + '</td><td style="text-align: right;"><a onClick="parent.destroyContext()"><img src="./themes/default/img/close.png" /></a></td></tr><tr class="albCtxt"><td class="albCtxt" colspan="2"><iframe id="albInfo" class="albCtxt"></iframe></td></tr></table>
   var targetFrame = document.getElementById('albInfo');
//   if (srchType == 'art') {
      targetFrame.src = './widgets/trafTrkAddCtxt.php?s=' + srchStr;
//   } else if (srchType == 'alb') {
//      targetFrame.src = './widgets/albumInfoContext.php?albId=' + srchStr;
//   }
   targetFrame.setAttribute('target','main');
}

//function trafTrkAddId (trkId) {
//   frames['main'].document.getElementById('trafTrkAddId').innerHTML = '<input type="hidden" value="" ';
//}

</script>

<script language="javascript" type="text/javascript">
function destroyContext () {
   var contextMenu = document.getElementById('contextMenu');
//   var contextStatus = document.getElementById('contextMenuStatus');
//   if (contextStatus.innerHTML == 1) {
//      contextStatus.innerHTML = 0;
      contextMenu.className = 'hidden';
      contextMenu.innerHTML = '';
//   } else {
//      contextStatus.innerHTML = 1;
//   }
}

function albSetMultiQuery (albId, albMulti, posX, posY) {
   var targetDiv = document.getElementById('contextMenu');
   targetDiv.style.top = posY + 'px';
   targetDiv.style.left = posX + 'px';
   targetDiv.style.position = 'absolute';
   targetDiv.className = 'albumContext';
   targetDiv.innerHTML = '<iframe id="albSetMultiCtxt" class="albCtxt"></iframe>';
   var targetFrame = document.getElementById('albSetMultiCtxt');
   targetFrame.src = './widgets/albSetMultiCtxt.php?albId=' + albId + '&albMulti=' + albMulti;
   targetFrame.setAttribute('target','main'); 
   
}
   
//   alert(contextMenu.className);
//   if (contextMenu.className != 'hidden') {
//      contextMenu.className = 'hidden';
//      contextMenu.innerHTML = '';
//   }
//   document.getElementById('contextMenu').className = 'hidden';
//   document.getElementById('contextMenu').innerHTML = '';
//}
</script>
</head>

<body>
<table style="height: 100%; width: 100%;">
<tr>
<td style="width: 202px; height: 100px;"><iframe src="sideHead.php" name="sideHead" scrolling="no"></iframe></td>
<td rowspan="2"><iframe name="main" src="main.php<?php if($_REQUEST['mode']) echo('?mode='.$_REQUEST['mode']) ?>"></iframe></td>
</tr>
<tr><td style="width: 202px;"><iframe name="sidebar" src="sidebar.php"></iframe></td></tr>
</tr>
</table><!-- iframe id="iframeContext" src="./widgets/blank.inc" class="hidden"></iframe -->
<div id="contextMenu" class="hidden"></div>
<!-- span id="contextMenuStatus" class="hidden">0</span -->
<!-- iframe id="iframeContext" class="hidden"></iframe -->
<script language="javascript">
  Drag.init(document.getElementById("contextMenu"));
</script>
</body>
</html><?php
}
/*
?>

<!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/xhtml1-frameset.dtd">
<frameset cols="200,*" frameborder="0" framespacing="0">
<frameset rows="100,*" frameborder="0" framespacing="0">
<frame src="sideHead.php" name="sideHead" noresize="noresize" scrolling="no" />
<!-- frame src="sidebar.php" name="sidebar" noresize="noresize" scrolling="yes" />
</frameset>
<frame src="index.php" name="main" noresize="noresize" scrolling="yes" />
</frameset>
<?php 
*/
?>
